package cn.xshi.monitor.service.impl;
import java.util.List;
import java.util.Map;
import cn.xshi.common.base.BaseService;
import cn.xshi.common.util.ExceptionUtil;
import cn.xshi.monitor.dao.IotDeviceTypeDao;
import cn.xshi.monitor.model.IotDeviceType;
import cn.xshi.monitor.service.IotDeviceTypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
/**
 * @Desc 设备类型
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Service
public class IotDeviceTypeServiceImpl extends BaseService implements IotDeviceTypeService {

	@Resource
	private IotDeviceTypeDao iotDeviceTypeDao;

	/**
	* 分页
	* @param condition 
	* @return
	*/
	public List<IotDeviceType> getIotDeviceTypeListByCondition(Map<String,Object> condition){
		try{
			return iotDeviceTypeDao.getIotDeviceTypeListByCondition(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 查询对象
	* @param id
	* @return
	*/
	public IotDeviceType getIotDeviceTypeById(String id){
		try{
			IotDeviceType iotDeviceType = iotDeviceTypeDao.getIotDeviceTypeById(id);
			return iotDeviceType;
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 添加
	* @param iotDeviceType 
	* @return
	*/
	public int addIotDeviceType(IotDeviceType iotDeviceType){
		int i = 0;
		try {
			iotDeviceType.setCreateTime(getDate());
			iotDeviceType.setId(toUUID());
			iotDeviceType.setCreateId(getCurrentAccountId());
			i = iotDeviceTypeDao.addIotDeviceType(iotDeviceType);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改
	* @param iotDeviceType 
	* @return
	*/
	public int updateIotDeviceType(IotDeviceType iotDeviceType){
		int i = 0;
		try {
			iotDeviceType.setUpdateId(getCurrentAccountId());
			iotDeviceType.setUpdateTime(getDate());
			i = iotDeviceTypeDao.updateIotDeviceType(iotDeviceType);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改（根据动态条件）
	* @param iotDeviceType 
	* @return
	*/
	public int updateIotDeviceTypeBySelective(IotDeviceType iotDeviceType){
		int i = 0;
		try {
			iotDeviceType.setUpdateId(getCurrentAccountId());
			i = iotDeviceTypeDao.updateIotDeviceTypeBySelective(iotDeviceType);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 删除
	* @param condition 
	* @return
	*/
	public int delIotDeviceType(Map<String,Object> condition){
		int i = 0;
		try {
			i = iotDeviceTypeDao.delIotDeviceType(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 批量修改
	* @param iotDeviceTypeList 
	* @return
	*/
	public int updateBatchIotDeviceType(List<IotDeviceType> iotDeviceTypeList){
		int i = 0;
		try {
			i = iotDeviceTypeDao.updateBatchIotDeviceType(iotDeviceTypeList);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 批量修改（根据动态条件）
	* @param iotDeviceTypeList 
	* @return
	*/
	public int updateBatchIotDeviceTypeBySelective(List<IotDeviceType> iotDeviceTypeList){
		int i = 0;
		try {
			i = iotDeviceTypeDao.updateBatchIotDeviceTypeBySelective(iotDeviceTypeList);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	 * 查询相机类型
	 * @param condition
	 * @return
	 */
	public List<IotDeviceType> getVideoTypeList(Map<String, Object> condition){
		try{
			return iotDeviceTypeDao.getVideoTypeList(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}
}
